Xbasic

DBCOUNT Function

Syntax

Number_of_Records as N = DBCOUNT(C tablename,C tagname,A keyvalue)

Arguments

tablename

The full drive, path, name, and extension of the table. If you omit the drive, path, and extension, Alpha Anywhere searches the directory of the current table.

tagname

The name of an index.

keyvalue

An explicit value or the name of a field in the table containing a value.

Description

Returns the number of matching records in a specified table.

Discussion

DBCOUNT() searches the specified Table for one or more records with the specified Key_Value, and returns the number of records found. Note : If no records with matching key values are found, Alpha Anywhere returns a zero value.

Example

Assume that a customer order table (ORDER) contains the following records:

CUSTOMER_ID

AMOUNT

C100

234.45

C100

123.67

C100

100.23

C101

231.34

C102

111.12

C102

987.23

The following expression returns the count of the number of records in the ORDER table with a customer ID number of "C102":

? dbcount("order.dbf", "CUSTOMER_ID", "C102")
= 2

This example uses the Customer_ID index to count the number of items ordered by customer ID "00000004".

? dbcount("invoice_header", "Customer_Id", "00000004")
= 2

This example uses the Sales_Tax index to count the number of items with a tax rate of 5 percent.

? dbcount("invoice_header", "Sales_Tax", 5)
= 20
dim rate as N = 5
? dbcount("invoice_header", "Sales_Tax", rate)
= 20

See Also